package net.xxcl.kygl.service;

import java.util.List;
import net.xxcl.kygl.mapper.LoginMapper;
import net.xxcl.kygl.pojo.Criteria;
import net.xxcl.kygl.pojo.Login;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginService {
    @Autowired
    private LoginMapper loginMapper;

    private static final Logger logger = LoggerFactory.getLogger(LoginService.class);

    public int countByExample(Criteria example) {
        int count = this.loginMapper.countByExample(example);
        logger.debug("count: {}", count);
        return count;
    }

    public Login selectByPrimaryKey(Integer id) {
        return this.loginMapper.selectByPrimaryKey(id);
    }

    public List<Login> selectByExample(Criteria example) {
        return this.loginMapper.selectByExample(example);
    }

    public int deleteByPrimaryKey(Integer id) {
        return this.loginMapper.deleteByPrimaryKey(id);
    }

    public int updateByPrimaryKeySelective(Login record) {
        return this.loginMapper.updateByPrimaryKeySelective(record);
    }

    public int updateByPrimaryKey(Login record) {
        return this.loginMapper.updateByPrimaryKey(record);
    }

    public int deleteByExample(Criteria example) {
        return this.loginMapper.deleteByExample(example);
    }

    public int updateByExampleSelective(Login record, Criteria example) {
        return this.loginMapper.updateByExampleSelective(record, example);
    }

    public int updateByExample(Login record, Criteria example) {
        return this.loginMapper.updateByExample(record, example);
    }

    public int insert(Login record) {
        return this.loginMapper.insert(record);
    }

    public int insertSelective(Login record) {
        return this.loginMapper.insertSelective(record);
    }

    /**
     * 判断登录名是否存在
     * @param example
     * @return
     */
    public boolean isNameExist(Criteria example) {
        if(this.loginMapper.isNameExist(example).size()>0){
            return true;
        } else {
            return false;
        }
    }
}